//
//  HWDividedIntoViewController.m
//  HWPromoteProjectAPP
//
//  Created by 陈道斌 on 2020/2/18.
//  Copyright © 2020 陈道斌. All rights reserved.
// 分成明细

#import "HWDividedIntoViewController.h"
#import "HWDividedIntoCell.h"
#import "HWjiesunbiaotiTableViewCell.h"

@interface HWDividedIntoViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(strong,nonatomic) UITableView *mainaTableVie;
@property(strong,nonatomic) NSMutableArray *dataMuArr;

@end

@implementation HWDividedIntoViewController



-(UITableView *)mainaTableVie {
    
    if  (_mainaTableVie == nil) {
        
        _mainaTableVie = [[UITableView alloc]initWithFrame:CGRectMake(20*CFLScaleValue, 10, kScreenW-40*CFLScaleValue, kScreenH-40) style:UITableViewStylePlain];
        // _mainaTableVie = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kScreenW, kScreenH-44) style:UITableViewStylePlain];
     //   _mainaTableVie.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
        _mainaTableVie.delegate = self;
        _mainaTableVie.dataSource = self;
        _mainaTableVie.separatorStyle = UITableViewCellSeparatorStyleNone;
        _mainaTableVie.backgroundColor = beijingyanSe;
        _mainaTableVie.layer.cornerRadius = 12;
        _mainaTableVie.layer.masksToBounds = YES;
    
       // _mainaTableVie.backgroundColor = [UIColor whiteColor];
    }
    
    
    return   _mainaTableVie;
    
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    self.navigationController.navigationBarHidden = NO;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self setupUI];
    [self sendNetworkRequest];
    
    
     
    
    
}


- (void)setupUI {
    
    self.view.backgroundColor = beijingyanSe;
    
    self.navigationItem.title = @"分成明细";
    
    [self.view addSubview:self.mainaTableVie];
    
   
    
    
}



// 发送网络请求
- (void)sendNetworkRequest {
    
    
    
     
         NSString *tStr = [NSString stringWithFormat:@"%ld",[WMUtil getTimeSp]];
         NSString *uid =  [HWLocallyStoredData getLoginUserID];
         NSString *signStr = [NSString stringWithFormat:@"%@%@%@",uid,tStr,@"adesxloksy13s98adv"];
         NSString  *signStrMd5  =   [WMUtil md5HexDigest:signStr];
           
        
        
        
          NSDictionary *parametes = @{      @"ios" : @"1",
                                       @"ct" : @"app",
                                        @"ac" : @"fencheng",
                                        @"t" : tStr,
                                        @"uid":uid,
                                        @"sign" :signStrMd5
                                        };
        
        
            [HWWebUtils doGetWithParameters:parametes progress:nil success:^(id response) {
                  
                 

                  NSString *codeStr =  [NSString stringWithFormat:@"%@",response[@"code"]];
                  if ([codeStr intValue] == 1) {
                 
                      self.dataMuArr = [[NSMutableArray alloc]init];
                      NSDictionary *dic = @{@"income":@"12"};
                      [self.dataMuArr addObject:dic];
                      NSArray *arr = response[@"data"];
                      for (int i = 0; i < arr.count; i++) {
                          [self.dataMuArr addObject:arr[i]];
                          
                      }
                      [self.mainaTableVie reloadData];
                      
                        NSLog(@"%@",response);
                      
            
                      
                       
                  } else {
                      
                    [MBProgressHUD showError:response[@"message"]];
                                    
                
                      
                  }
                  
             
                  
              } failure:^(NSString *error) {
                 // [SVProgressHUD dismiss];
                  
                   [MBProgressHUD showSuccess:@"登录失败"];
                    [MBProgressHUD hideHUD];
                  
                  
              }];
        
    
    
    
    
    
    
    
}








- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    
    return  self.dataMuArr.count;
    
}



- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    
    if(indexPath.row == 0) {
        
        
        static NSString *cellID = @"cellID1";
          
          HWjiesunbiaotiTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
          
          if (!cell) {
              cell = [[HWjiesunbiaotiTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
              
          }
          cell.selectionStyle =  UITableViewCellSelectionStyleNone;
          if (indexPath.row == 0) {
              cell.backgroundColor = [UIColor whiteColor];
          } else {
              
              cell.backgroundColor = [UIColor whiteColor];
              
          }
          
    
        
          return  cell;
        
        
    }
    
    static NSString *cellID = @"cellID";
    
    HWDividedIntoCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    
    if (!cell) {
        cell = [[HWDividedIntoCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
        
    }
    cell.selectionStyle =  UITableViewCellSelectionStyleNone;
 
    cell.backgroundColor = [UIColor whiteColor];
      
    NSDictionary *dic  =  self.dataMuArr[indexPath.row];
    cell.dataDic = dic;
    
    
    
  
    return  cell;
    
    
}



- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    
    
    if(indexPath.row == 0) {
        
         return  52;
    }
    
     
    return  46;
    
    
    
    
}



@end
